/* 
 * File:   Exception.h
 * Author: dativa
 *
 * Created on 2 lipiec 2011, 12:03
 */

#ifndef _EXCEPTION_H
#define	_EXCEPTION_H

#include <cstring>
#include <cstdlib>

namespace dativa {

    class Exception {
    public:

        Exception() {
            message = strdup("");
        }

        Exception(const char* message) {
            this->message = strdup(message);
        }

        Exception(const Exception &exception) {
            this->message = strdup(exception.message);
        }

        virtual ~Exception() {
            free(message);
        }

        bool equals(const Exception& exception) const {
            return strcmp(message, exception.message) == 0;
        }

        const char* get_message() const {
            return message;
        }

        bool operator==(const Exception& exception) {
            return equals(exception);
        }

    private:
        char* message;

    };

}

#endif	/* _EXCEPTION_H */

